package customerEnter.Frame.ehcache.AvailableEhcache;

import java.util.List;

import net.sf.json.JSONArray;
import customerEnter.tool.WhetherToEmpty;

/**
 * 緩存驗證判斷
 * 
 * 类名称：EcacheJudge 类描述： 创建人：dy 创建时间：2016-4-29 上午10:22:25
 * 
 */
public class EcacheJudge {
	private static EcacheJudge	ecacheJudge;

	private EcacheJudge() {
	}

	public static EcacheJudge getEcacheJudge() {
		if (WhetherToEmpty.ObjectWhetherToEmpty(ecacheJudge)) {
			ecacheJudge = new EcacheJudge();
		}
		return ecacheJudge;
	}

	/**
	 * 判斷有沒有 key 默認有
	 */
	public Boolean IfEhcache(Object key) {
		Boolean bool = true;
		try {
			if (WhetherToEmpty.ObjectWhetherToEmpty(EcacheDataTransmission.getEcacheDataTransmission().getElementEach(
					key))) {
				bool = false;
			}
		} catch (Exception e) {
			bool = false;
		}
		return bool;
	}

	/**
	 * 判斷list 是否為空
	 */
	public Boolean listNullOrIs(List<?> list) {
		Boolean bool = false;
		// 不為空
		if (!WhetherToEmpty.ListWhetherToEmpty(list)) {
			bool = true;
		}
		return bool;
	}

	/**
	 * 判斷json數組是否為空
	 */
	public Boolean JsonArrayNullOrIs(JSONArray jsonArray) {
		Boolean bool = false;
		if (!WhetherToEmpty.ObjectWhetherToEmpty(jsonArray)) {
			bool = true;
		}
		return bool;
	}

}
